package cn.gson.boot.model.service;

import cn.gson.boot.model.dao.BusinessDao;
import cn.gson.boot.model.dao.HuiKuanDao;
import cn.gson.boot.model.dao.KaiPiaoDao;
import cn.gson.boot.model.mapper.BusinessMapper;
import cn.gson.boot.model.mapper.KaiPiaoMapper;
import cn.gson.boot.model.pojos.Business;
import cn.gson.boot.model.pojos.Kaipiao;
import cn.gson.boot.model.pojos.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class KaiPiaoService {
    @Autowired
    KaiPiaoDao kaiPiaoDao;
    @Autowired
    KaiPiaoMapper kaiPiaoMapper;
    @Autowired
    HuiKuanDao huiKuanDao;

    //根据订单id找到此订单的所有开票记录
    public List<Kaipiao> selectKaiPiaoByddId(Integer ddId){
        return kaiPiaoMapper.selectKaiPiaoByddId(ddId);
    }

    //新增开票记录
    public void addKaiPiao(Kaipiao kaipiao) {
        kaiPiaoDao.save(kaipiao);
        //修改回款是否开发票的状态为：是
        huiKuanDao.updateHuiKuanFaPiaoIsYes(kaipiao.getHuikuan().getHkId());
    }

    //查开票员工
    public List<User> selectKaiPiaoEmp(){
        return kaiPiaoMapper.selectKaiPiaoEmp();
    }

    //根据回款id查看开票记录
    public Kaipiao selectKaiPiaoByhkId(Integer hkId){
        return kaiPiaoMapper.selectKaiPiaoByhkId(hkId);
    }
}
